<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<%
	String pid = request.getParameter("channelId");
%>
<html>
	<head>
		<script type="text/javascript">
		
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		   			       var keyValue = n.id;
			       row.find(".klId").attr("value",n.channel_name);
		           row.find(".klId").attr("id",n.id);
			   	
			       row.find(".klchannel_name").text(n.channel_name);
			   	
			       row.find(".klremarks").text(n.remarks);
			   	
		 		   row.attr("id","ready"+i);
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");
		       });   
			}
			
			function _checkChannel(obj){
			    var id = obj.id;
			    var channelName = obj.value;
		    	var thisChannel = document.getElementById(id);
		    	//userid1|username1
		    	var checkedStr = parent.document.getElementById("checkedStr").value;
		    	if(thisChannel.checked){
			    	checkedStr = id+"$"+channelName;
			    }
		    	parent.document.getElementById("checkedStr").value = checkedStr;
		    }
		</script>
	</head>
<body>
<form name="frm" method="post" style="margin: 0" action="<%=path%>/cms/channel/list?pid=<%=pid %>" id="frm">
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px" >
						选择
					</td>   
		      		<td>
						频道名称
					</td>   
		      		<td>
						备注
					</td>   
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="radio" onclick="_checkChannel(this)" name="checkChannel" class="klId" />
					</td>
		   		    <td class="klchannel_name niceTable-left"></td>
		   		    <td class="klremarks niceTable-left"></td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td style="border-right: none">
						<img class="loading"
							src="/resources/skins/default/images/large-loading.gif" width="20px"
							class="hidden" />
					</td>
					<td colspan="4" style="border-left: none" class="txtRight">
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>
	<input type="hidden" id="checkedStr" name="checkedStr"/>
</body>
<script type="text/javascript">
$(function(){
	//加载两个要使用json分页的组件
    loadGird("frm", 1);
    setTimeout(initr,"1000");//
})

function initr(){
	var allChannels = document.getElementsByName("checkChannel");
   	var checkedStr = parent.document.getElementById("checkedStr").value;
   	if(checkedStr == "|"){
   		checkedStr = document.getElementById("checkedStr").value;
   	}
   	if(allChannels){
	   	for(var i = 1;i<allChannels.length;i++){
	   		if(checkedStr.indexOf(allChannels[i].id) != -1 ){
	   			allChannels[i].checked = true;
	   			break;
	   		}
	   	}
   	}
}
</script>
</html>
